<template>
  <div class="mod-config">
    <basic-container>
      <navigationZDRW :sign="{ a: false, b: false, c: true }"></navigationZDRW>
      <div v-if="showZhong == 1" class="boxsty zhiBiao">
        <div :height="searchheight">
          <span
            style="float: right; margin-top: -30px; cursor: pointer"
            @click="searchchangeadvanced"
            >{{ searchadvanced ? "查询条件收起" : "查询条件展开" }}
            <i
              :class="
                searchadvanced ? 'el-icon-arrow-up' : 'el-icon-arrow-down'
              "
            />
          </span>
          <div v-show="searchadvanced">
            <el-form
              :inline="true"
              :model="dataForm"
              @keyup.enter.native="getDataList()"
              class="form-inline"
            >
              <el-form-item label="发起名称">
                <el-input
                  v-model="dataForm.faqiName"
                  placeholder="发起名称"
                  :clearable="true"
                  style="width: 150px"
                ></el-input>
              </el-form-item>
              <el-form-item label="被考核人姓名">
                <el-input
                  v-model="dataForm.ryName"
                  placeholder="被考核人姓名"
                  :clearable="true"
                  style="width: 150px"
                ></el-input>
              </el-form-item>
              <el-form-item label="被考核人岗位">
                <el-input
                  v-model="dataForm.userZw"
                  placeholder="被考核人岗位"
                  :clearable="true"
                  style="width: 150px"
                ></el-input>
              </el-form-item>
              <el-form-item label="任务书状态">
                <el-select
                  style="width: 150px"
                  v-model="dataForm.state"
                  placeholder="请选择"
                  clearable
                >
                  <el-option value="12" label="履约中"></el-option>
                  <el-option value="13" label="自评中"></el-option>
                  <el-option value="14" label="评价中"></el-option>
                  <el-option value="15" label="结果汇总完成"></el-option>
                  <el-option value="16" label="领导审核中"></el-option>
                  <el-option value="17" label="领导审核完成"></el-option>
                  <el-option value="18" label="审核结束"></el-option>
                </el-select>
              </el-form-item>
              <el-form-item>
                <el-button
                  icon="el-icon-search"
                  type="primary"
                  class="marginLeft"
                  @click="getDataList(1)"
                  >检索
                </el-button>
              </el-form-item>
            </el-form>
          </div>
        </div>
        <div class="border-top-theme"></div>
        <el-table
          style="width: 100%; margin-top: 20px"
          :data="dataList"
          border
          v-loading="dataListLoading"
        >
          <el-table-column
            type="selection"
            width="55"
            header-align="center"
            align="center"
          ></el-table-column>
          <el-table-column
            type="index"
            width="80"
            header-align="center"
            align="center"
            label="序号"
          ></el-table-column>
          <el-table-column
            prop="faqiName"
            header-align="center"
            align="center"
            width="200"
            show-overflow-tooltip
            label="发起名称"
          >
          </el-table-column>
          <el-table-column
            prop="ryName"
            header-align="center"
            align="center"
            min-width="120"
            label="被考核人姓名"
          >
          </el-table-column>
          <el-table-column
            prop="userZw"
            header-align="center"
            align="center"
            min-width="120"
            label="被考核人岗位"
          >
          </el-table-column>
          <el-table-column
            prop="zp"
            header-align="center"
            align="center"
            min-width="120"
            label="自评分"
          >
          </el-table-column>
          <el-table-column
            prop="pj"
            header-align="center"
            align="center"
            min-width="120"
            label="领导评分"
          >
          </el-table-column>
          <el-table-column
            prop="order"
            header-align="center"
            align="center"
            min-width="120"
            label="其他奖惩"
          >
          </el-table-column>
          <el-table-column
            prop="count"
            header-align="center"
            min-width="110"
            align="center"
            label="最终评分"
          >
            <template slot-scope="scope">
              <span v-if="scope.row.count == '-'">-</span>
              <span v-else>{{ scope.row.count.toFixed(2) }}</span>
            </template>
          </el-table-column>
          <el-table-column
            prop="xiu"
            header-align="center"
            align="center"
            min-width="110"
            label="修正系数"
          >
          </el-table-column>
          <el-table-column
            prop="nan"
            header-align="center"
            align="center"
            min-width="110"
            label="难度系数"
          >
          </el-table-column>
          <el-table-column
            prop="score"
            header-align="center"
            align="center"
            min-width="110"
            label="考核得分"
          >
          </el-table-column>
          <el-table-column
            prop="stateExplain"
            header-align="center"
            align="center"
            min-width="120"
            label="任务状态"
          >
          </el-table-column>
          <el-table-column
            header-align="center"
            align="center"
            width="300"
            fixed="right"
            label="操作"
          >
            <template slot-scope="scope">
              <el-button
                type="primary"
                plain
                size="small"
                @click="preview(scope.row)"
                >自评</el-button
              >
              <el-button
                type="primary"
                plain
                size="small"
                @click="evaluation(scope.row)"
                >领导评分</el-button
              >
              <el-button
                type="primary"
                plain
                size="small"
                @click="cheekBtn(scope.row)"
                >综合得分</el-button
              >
            </template>
          </el-table-column>
        </el-table>
        <div class="avue-crud__pagination">
          <el-pagination
            @size-change="sizeChangeHandle"
            @current-change="currentChangeHandle"
            :current-page="pageIndex"
            :page-sizes="[10, 20, 50, 100]"
            :page-size="pageSize"
            :total="totalPage"
            background
            layout="total, sizes, prev, pager, next, jumper"
          >
          </el-pagination>
        </div>
      </div>
      <zdfqForm
        v-if="showZhong == 2"
        ref="zdfqRef"
        :zdfqForm="zdfqForm"
        v-on:zdrwfqC="zdrwfqC"
      ></zdfqForm>
      <!--          任务自评-->
      <zdzpForm
        v-if="showZhong == 3"
        ref="renwuziping"
        :titleForm="titleForm"
        @fnBackLastPage="fnBackLastPage"
      ></zdzpForm>
      <zhCheek
        ref="zhCheek"
        v-if="showZhong == 4"
        @childrenEvent="showZhong = 1"
      ></zhCheek>
    </basic-container>
  </div>
</template>

<script>
import zhCheek from "../zhCheek.vue";
import zdfqForm from "@/views/hetongrenwu/components/zhongdianfq-form.vue";
import zdzpForm from "@/views/hetongrenwu/components/zhongdianzp-form.vue";
import { radioTwoList } from "@/api/hetongrenwu/hetonghtxxdjb";
import { validatenull } from "@/util/validate";
import {
  fetchListHzCk,
  getScore,
  getScorePj,
  tibao,
} from "@/api/hetongrenwu/zhongdian/renwutianbao";
import { getObj, zzdfList } from "@/api/hetongrenwu/zhongdian/renwuchuangjian";
export default {
  components: {
    zdfqForm,
    zdzpForm,
    zhCheek,
  },
  data() {
    return {
      optionsStatus: [
        {
          value: 0,
          label: "未发起",
        },
        {
          value: 1,
          label: "已发起",
        },
        {
          value: 2,
          label: "已自评",
        },
        {
          value: 3,
          label: "已评价",
        },
        {
          value: 4,
          label: "已汇总",
        },
      ],
      titleForm: {},
      showZhong: 1,
      dataForm: {},
      radio: "1",
      radioTwo: "1",
      dataList: [],
      pageIndex: 1,
      pageSize: 10,
      totalPage: 0,
      dataListLoading: false,
      zdfqForm: {},
      searchadvanced: true,
      searchheight: "0",
      radioTwoList: radioTwoList,
    };
  },
  created() {
    let params = this.$route.query;
    if (!validatenull(params)) {
      this.radioTwo = params.radioTwo;
    }
    this.getDataList();
  },
  methods: {
    searchchangeadvanced() {
      this.searchadvanced = !this.searchadvanced;
      if (this.searchadvanced) {
        this.searchheight = "auto";
      }
    },
    //查看评价
    evaluation(row) {
      getScorePj({ id: row.id, showAll: 1 }).then((res) => {
        this.showZhong = 2;
        this.$nextTick(() => {
          this.zdfqForm = {
            enter: "3",
            disabled: true,
          };
          this.$refs.zdfqRef.init(res.data.data, "rwck");
        });
      });
    },
    //子集
    zdrwfqC(zdrwfqC) {
      if (zdrwfqC) {
        this.showZhong = 1;
      }
    },
    cheekBtn(row) {
      zzdfList({ id: row.recordId }).then((res) => {
        this.showZhong = 4;
        this.$nextTick(() => {
          this.$refs.zhCheek.init(res.data.data, row);
        });
      });
    },
    getDataList() {
      this.dataListLoading = true;
      fetchListHzCk(
        Object.assign(
          {
            current: this.pageIndex,
            size: this.pageSize,
          },
          this.dataForm
        )
      ).then((response) => {
        //console.log(response)
        this.dataList = response.data.data.records;
        this.totalPage = response.data.data.total;
      });
      this.dataListLoading = false;
    },
    // 每页数
    sizeChangeHandle(val) {
      this.pageSize = val;
      this.pageIndex = 1;
      this.getDataList();
    },
    // 当前页
    currentChangeHandle(val) {
      this.pageIndex = val;
      this.getDataList();
    },
    //查看自评
    preview(row) {
      getObj(row.id).then((res) => {
        row.start = res.data.data.rwYxqq;
        row.end = res.data.data.rwYxqz;
        getScore({ id: row.id }).then((res) => {
          this.titleForm = row;
          this.showZhong = 3;
          this.$nextTick(() => {
            var data = {
              dataForm: {
                dataList: res.data.data,
              },
              showTextarea: "hzziping",
            };
            this.$refs.renwuziping.init(data);
          });
        });
      });
    },
    //任务考核返回数据
    fnBackLastPage(data) {
      if (data == "返回原页面") {
        this.showZhong = 1;
      }
    },
    //提报
    tibao(row) {
      this.$confirm("是否要提报该条数据?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          tibao(row)
            .then((res) => {
              this.$message({
                type: "success",
                message: "提报成功!",
              });
              this.getDataList();
            })
            .catch(() => {
              this.$message({
                type: "error",
                message: "提报失败!",
              });
            });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消提报",
          });
        });
    },
  },
};
</script>

<style>
</style>
